package androidx.cardview.widget;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.MeasureSpec;
import android.widget.FrameLayout;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Px;
import o.dk.a;
import o.dk.c;
import o.dk.d;
import o.dk.e;
import o.dl;
import o.dm;
import o.dn;
import o.do;
import o.dp;

public class CardView extends FrameLayout {
    private static final dm ʻ;
    private static final int[] ˋ = new int[]{16842801};
    private final do ʼ;
    int ˊ;
    int ˎ;
    final Rect ˏ;
    final Rect ॱ;
    private boolean ॱॱ;
    private boolean ᐝ;

    static {
        if (VERSION.SDK_INT >= 21) {
            ʻ = new dl();
        } else if (VERSION.SDK_INT >= 17) {
            ʻ = new dp();
        } else {
            ʻ = new dn();
        }
        ʻ.ˎ();
    }

    public CardView(@NonNull Context context) {
        this(context, null);
    }

    public CardView(@NonNull Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, c.ˎ);
    }

    public CardView(@NonNull Context context, @Nullable AttributeSet attributeSet, int i) {
        ColorStateList colorStateList;
        int color;
        super(context, attributeSet, i);
        this.ˏ = new Rect();
        this.ॱ = new Rect();
        this.ʼ = new do(this) {
            final /* synthetic */ CardView ˋ;
            private Drawable ॱ;

            {
                this.ˋ = r1;
            }

            public void ˎ(Drawable drawable) {
                this.ॱ = drawable;
                this.ˋ.setBackgroundDrawable(drawable);
            }

            public boolean ˏ() {
                return this.ˋ.l_();
            }

            public boolean ˋ() {
                return this.ˋ.ʻ();
            }

            public void ॱ(int i, int i2, int i3, int i4) {
                this.ˋ.ॱ.set(i, i2, i3, i4);
                super.setPadding(this.ˋ.ˏ.left + i, this.ˋ.ˏ.top + i2, this.ˋ.ˏ.right + i3, this.ˋ.ˏ.bottom + i4);
            }

            public void ॱ(int i, int i2) {
                if (i > this.ˋ.ˎ) {
                    super.setMinimumWidth(i);
                }
                if (i2 > this.ˋ.ˊ) {
                    super.setMinimumHeight(i2);
                }
            }

            public Drawable ॱ() {
                return this.ॱ;
            }

            public View ˊ() {
                return this.ˋ;
            }
        };
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, e.ˎ, i, d.ˎ);
        if (obtainStyledAttributes.hasValue(e.ˏ)) {
            colorStateList = obtainStyledAttributes.getColorStateList(e.ˏ);
        } else {
            TypedArray obtainStyledAttributes2 = getContext().obtainStyledAttributes(ˋ);
            int color2 = obtainStyledAttributes2.getColor(0, 0);
            obtainStyledAttributes2.recycle();
            float[] fArr = new float[3];
            Color.colorToHSV(color2, fArr);
            if (fArr[2] > 0.5f) {
                color = getResources().getColor(a.ˏ);
            } else {
                color = getResources().getColor(a.ॱ);
            }
            colorStateList = ColorStateList.valueOf(color);
        }
        float dimension = obtainStyledAttributes.getDimension(e.ॱ, 0.0f);
        float dimension2 = obtainStyledAttributes.getDimension(e.ʽ, 0.0f);
        float dimension3 = obtainStyledAttributes.getDimension(e.ʻ, 0.0f);
        this.ॱॱ = obtainStyledAttributes.getBoolean(e.ʼ, false);
        this.ᐝ = obtainStyledAttributes.getBoolean(e.ॱॱ, true);
        color = obtainStyledAttributes.getDimensionPixelSize(e.ᐝ, 0);
        this.ˏ.left = obtainStyledAttributes.getDimensionPixelSize(e.ˏॱ, color);
        this.ˏ.top = obtainStyledAttributes.getDimensionPixelSize(e.ͺ, color);
        this.ˏ.right = obtainStyledAttributes.getDimensionPixelSize(e.ॱˊ, color);
        this.ˏ.bottom = obtainStyledAttributes.getDimensionPixelSize(e.ˊॱ, color);
        if (dimension2 > dimension3) {
            dimension3 = dimension2;
        }
        this.ˎ = obtainStyledAttributes.getDimensionPixelSize(e.ˋ, 0);
        this.ˊ = obtainStyledAttributes.getDimensionPixelSize(e.ˊ, 0);
        obtainStyledAttributes.recycle();
        ʻ.ˋ(this.ʼ, context, colorStateList, dimension, dimension2, dimension3);
    }

    public void setPadding(int i, int i2, int i3, int i4) {
    }

    public void setPaddingRelative(int i, int i2, int i3, int i4) {
    }

    public boolean l_() {
        return this.ॱॱ;
    }

    public void setUseCompatPadding(boolean z) {
        if (this.ॱॱ != z) {
            this.ॱॱ = z;
            ʻ.ʽ(this.ʼ);
        }
    }

    public void setContentPadding(@Px int i, @Px int i2, @Px int i3, @Px int i4) {
        this.ˏ.set(i, i2, i3, i4);
        ʻ.ॱ(this.ʼ);
    }

    protected void onMeasure(int i, int i2) {
        if (ʻ instanceof dl) {
            super.onMeasure(i, i2);
            return;
        }
        int mode = MeasureSpec.getMode(i);
        switch (mode) {
            case Integer.MIN_VALUE:
            case 1073741824:
                i = MeasureSpec.makeMeasureSpec(Math.max((int) Math.ceil((double) ʻ.ˊ(this.ʼ)), MeasureSpec.getSize(i)), mode);
                break;
        }
        mode = MeasureSpec.getMode(i2);
        switch (mode) {
            case Integer.MIN_VALUE:
            case 1073741824:
                i2 = MeasureSpec.makeMeasureSpec(Math.max((int) Math.ceil((double) ʻ.ˎ(this.ʼ)), MeasureSpec.getSize(i2)), mode);
                break;
        }
        super.onMeasure(i, i2);
    }

    public void setMinimumWidth(int i) {
        this.ˎ = i;
        super.setMinimumWidth(i);
    }

    public void setMinimumHeight(int i) {
        this.ˊ = i;
        super.setMinimumHeight(i);
    }

    public void setCardBackgroundColor(@ColorInt int i) {
        ʻ.ˏ(this.ʼ, ColorStateList.valueOf(i));
    }

    public void setCardBackgroundColor(@Nullable ColorStateList colorStateList) {
        ʻ.ˏ(this.ʼ, colorStateList);
    }

    @Px
    public int m_() {
        return this.ˏ.left;
    }

    @Px
    public int n_() {
        return this.ˏ.right;
    }

    @Px
    public int ॱ() {
        return this.ˏ.top;
    }

    @Px
    public int o_() {
        return this.ˏ.bottom;
    }

    public void setRadius(float f) {
        ʻ.ˏ(this.ʼ, f);
    }

    public float ʽ() {
        return ʻ.ˏ(this.ʼ);
    }

    public void setCardElevation(float f) {
        ʻ.ॱ(this.ʼ, f);
    }

    public void setMaxCardElevation(float f) {
        ʻ.ˎ(this.ʼ, f);
    }

    public boolean ʻ() {
        return this.ᐝ;
    }

    public void setPreventCornerOverlap(boolean z) {
        if (z != this.ᐝ) {
            this.ᐝ = z;
            ʻ.ʼ(this.ʼ);
        }
    }
}
